<?php
if(!isset($_SESSION["connect"])||!$_SESSION["connect"]){
    Atomik::redirect("?");
}
switch ($_GET['route'])
{
    case "user":
        redirect_user();
        break;
    case "admin":
        redirect_admin();
        break;
    default :
        $this->redirect('?');
        break;
}

function redirect_user()
{
    $out = Atomik::execute('user/'.'_'.$_GET['action_user']);
    echo $out[0];
}

function redirect_admin()
{
    if(isset($_SESSION["admin_login"])&&isset($_SESSION["admin_key"])){
        Atomik::needed("propel");
        $query = TabAdminQuery::create()->filterByLogin($_SESSION["admin_login"])->findOne();
        if($query!=null){
            if(md5($query->getPass())==$_SESSION["admin_key"]){
                $out = Atomik::execute('admin/'.'_'.$_GET['action_admin']);
                echo $out[0];
            }
            else{
                Atomik::redirect('?');
            }
        }
        else{
            Atomik::redirect('?');
        }
    }
    else{
        Atomik::redirect('?');
    }
}
?>
